package graph_viewer.factory;

import graph_viewer.animator.*;
import graph_viewer.app_exception.*;
import graph_viewer.gui.*;
import graph_viewer.canvas.*;
import graph_viewer.drawer.*;
import graph_viewer.factory.*;
import graph_viewer.layout.*;
import graph_viewer.layout.layout_adjuster.*;
import graph_viewer.structure.*;
import graph_viewer.structure.clustering.*;
import graph_viewer.util.*;

public class  Layout_Factory{	

	/*public Layout create_layout(  String  layout_name, Drawer_Canvas a_graph_canvas ){
		if ( layout_name.equals(Layout.ABSTRACT_GRAPH_SPRING ) ){			
			return new Abstract_Graph_Spring( a_graph_canvas );			
		}else if ( layout_name.equals(Layout.DYNAMIC_NATURAL_LENGTH_SPRING) ){ 
			return new Dynamic_Natural_Length_Spring( a_graph_canvas );
		}else if ( layout_name.equals(Layout.ABSTRACT_GRAPH_ANNEALING) ){
			return new Abstract_Graph_Annealing( a_graph_canvas );
		}else if ( layout_name.equals(Layout.ABSTRACT_GARPH_RAW) ){
			return new Spring_Layout_Template( a_graph_canvas );
		}else if ( layout_name.equals(Layout.ABSTRACT_GRAPH_SPRING_DOUBLE_DIRECTION) ){
			return new Abstract_Graph_Spring_Double_Direction( a_graph_canvas );
		}else if ( layout_name.equals(Layout.ABSTRACT_GRAPH_ORTHGONAL_SPRING) ){
			return new Abstract_Graph_Orthgonal_Spring( a_graph_canvas );
		}else{
			throw new App_Exception( "Invalid Layout name for Layout_Factory to create layout." );
		}
	}*/
	public Layout create_layout(  String  layout_name ){
		if ( layout_name.equals(Layout.ABSTRACT_GRAPH_SPRING ) ){			
			return new Abstract_Graph_Spring( );			
		}else if ( layout_name.equals(Layout.ABSTRACT_GARPH_RAW) ){
			return new Spring_Layout_Template( );
		}else if ( layout_name.equals(Layout.DNLS) ){ 
			return new DNLS_Impl( );
		}/*else if ( layout_name.equals(Layout.ABSTRACT_GRAPH_ANNEALING) ){
			return new Abstract_Graph_Annealing( );
		}else if ( layout_name.equals(Layout.ABSTRACT_GRAPH_SPRING_DOUBLE_DIRECTION) ){
			return new Abstract_Graph_Spring_Double_Direction( );
		}*/else if ( layout_name.equals(Layout.ABSTRACT_GRAPH_ORTHGONAL_SPRING) ){
			return new Abstract_Graph_Orthgonal_Spring( );
		}else{
			throw new App_Exception( "Invalid Layout name for Layout_Factory to create layout." );
		}
	}

	public Layout_Adjuster create_adjuster( String ajuster_name ){

		if ( ajuster_name.equals( Cluttered_Nodes_Adjuster.NON_ADJUSTER ) ){
			return new Non_Adjuster();
		}else if ( ajuster_name.equals(Cluttered_Nodes_Adjuster.EADES_FORCE_SCAN ) ){
			return new Eades_Force_Scan_Adjuster( );
		}else if ( ajuster_name.equals(Cluttered_Nodes_Adjuster.HAYASHI_FORCE_SCAN_IMPROVEMENT ) ){
			return new Hayashi_Force_Scan_Improvement_Adjuster();
		}else if ( ajuster_name.equals(Cluttered_Nodes_Adjuster.HUANG_FORCE_TRANSFER ) ){
			return new Huang_Force_Transfer_Adjuster( );
		}else if ( ajuster_name.equals( Cluttered_Nodes_Adjuster.ODNLS ) ){
			return new ODNLS_Adjuster();
		}else if ( ajuster_name.equals( Cluttered_Nodes_Adjuster.DNLS ) ){
			return new DNLS_Adjuster();
		}/**/else{
			throw new App_Exception( "Invalid Adjuster name for Layout_Factory to create layout adjuster." );
		}	
	}

	public Layout_Adjuster create_cluttered_nodes_adjuster( String ajuster_name, Layout a_layout ){

		if ( ajuster_name.equals( Cluttered_Nodes_Adjuster.NON_ADJUSTER ) ){
			return new Non_Adjuster( a_layout );
		}else if ( ajuster_name.equals(Cluttered_Nodes_Adjuster.EADES_FORCE_SCAN ) ){
			return new Eades_Force_Scan_Adjuster( a_layout );
		}else if ( ajuster_name.equals(Cluttered_Nodes_Adjuster.HUANG_FORCE_TRANSFER ) ){
			return new Huang_Force_Transfer_Adjuster( a_layout );
		}else if ( ajuster_name.equals( Cluttered_Nodes_Adjuster.ODNLS ) ){
			return new ODNLS_Adjuster( a_layout );
		}else{
			throw new App_Exception( "Invalid Adjuster name for Layout_Factory to create layout adjuster." );
		}	
	}

	static private String get_non_adjuster_name(){
		
		int num_of_adjusters	= Cluttered_Nodes_Adjuster.ADJUSTER_VARIANTS.length;
		
		return Cluttered_Nodes_Adjuster.ADJUSTER_VARIANTS[ num_of_adjusters - 1 ] ;
	}
}